public class Calculator implements CalculatorInterface {
	@Override
	public double add(double... a) {
		double result = 0;
		for (int i=0; i < a.length; i++) {
			result += a[i];
		}
		return result;
	}

	@Override
	public double subtract(double... s) {
		double result = s[0];
		for (int i=1; i < s.length; i++) {
			result -= s[i];
		}
		return result;
	}

	@Override
	public double multiply(double... m) {

		double result = 1;

		for (int i = 0; i < m.length; i++) {

			result = result * m[i];
		}

		return result;
	}

	@Override
	public double divide(double... d) {
		
		double result = d[0];
		
		for(int i=1; i<d.length ;i++){
			if( d[i] == 0){
				System.out.println("Error! You can't divide 0");
				return 0;
			}else{
				result = result/d[i]; 
			}
		}
		return result;

		
	}
}
